<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $oid = $_REQUEST['oid'];
    $usuario = $_SESSION['usuario'];
    
    if($usuario == ""){
        print_r(json_encode(array('n'=>1)));
    }
    else{
        $count = "select count(*)as n from seginterpre where hcnsolexa = '".$oid."'";
        $res = $con->query($count);
        
        while($res2 = mssql_fetch_array($res)){
            $n = $res2['n'];
        }
        if($n == 0){
            $inser= "insert into seginterpre(hcnsolexa,infecha,inestado,usu_oid)values('".$oid."',GETDATE(),'1','".$_SESSION['usuario']."')";
            $con->query($inser);
        }else{
            $update = "update seginterpre
                        set infecha = GETDATE(),
                        inestado = '1',
                        usu_oid = '".$_SESSION['usuario']."'
                        where hcnsolexa = '".$oid."'";
            $con->query($update);
        }
        print_r(json_encode(array('n'=>2)));
    }
       
    $con->cerrarConexion();
    
 
?>